#ifndef __TWNREPORTBUILDER__
#define	__TWNREPORTBUILDER__ 1

#ifdef ALONE_TWNREPBUILDER
#include <iostream>
#include <stdio.h>
#include "ApmsApi.h"
#include "XlsObj.h"
#include "Tianwan.h"
#include "Uti_Tianwan.h"
#define VRP_API	extern "C" __declspec(dllexport)
#else
#define VRP_API	extern "C" __declspec(dllimport)
#endif

#define	PATH_LEN		256
#define FILE_NAME_LEN	256

//Define righe colonne foglio Excel template PSAS.//
#define	XLS_ROW_DOC_TYPE		3
#define	XLS_COL_DOC_TYPE		3
#define	XLS_ROW_DOC_NAME		4
#define	XLS_COL_DOC_NAME		3
#define	XLS_ROW_DOC_USER		5
#define	XLS_COL_DOC_USER		3
#define	XLS_ROW_DOC_DATE		6
#define	XLS_COL_DOC_DATE		3

#define	XLS_COL_INFO_TYPE		1
#define	XLS_COL_INFO			4
#define	XLS_ROW_INFO_FIRST		8
#define	XLS_ROW_INFO_LAST		15

#define	XLS_ROW_DATA_INIT		18
#define	XLS_COL_VIRT_X			1
#define	XLS_COL_VIRT_Y			2
#define XLS_COL_OBJ				3
#define XLS_COL_OBJT			4
#define XLS_COL_DATE			5

#define STR_NFA_CLUS	
#define FILE_NAME_LENGHT		127		

//Define righe colonne foglio Excel template RP.//
#define	XLS_ROW_DOC_NAME_RP		3
#define	XLS_ROW_DOC_DATE_RP		4
#define	XLS_ROW_DOC_TYPE_RP		5
#define	XLS_ROW_DOC_CAMP_RP		6
#define	XLS_ROW_DOC_TOTC_RP		7
#define	XLS_ROW_DOC_USER_RP		8
#define XLS_ROW_TECCYC_NUM_FRT	3
#define XLS_ROW_TECCYC_NUM_LST	10

#define XLS_COL_DATA			3
#define XLS_COL_TECCYC_DESCR	9
#define XLS_COL_TECCYC_NUM		13

#define XLS_ROW_DATA_INIT_RP	14

#define XLS_COL_TCID_RP			1
#define XLS_COL_TCDESCR_RP		2
#define XLS_COL_OBJT_RP			3
#define XLS_COL_OBJE_RP			4
#define XLS_COL_SVX_RP			5
#define XLS_COL_SVY_RP			6
#define XLS_COL_DVX_RP			7
#define XLS_COL_DVY_RP			8
#define XLS_COL_STTI_RP			9
#define XLS_COL_ENTI_RP			10
#define XLS_COL_STATUS_RP		11
#define XLS_COL_OPERATOR_SP		12
#define XLS_COL_SUPVIS_SP		13

//Define righe colonne foglio Excel template FALV.//
#define	XLS_FALV_ROW_DOC_TYPE		3
#define	XLS_FALV_COL_DOC_TYPE		3
#define	XLS_FALV_ROW_DOC_NAME		4
#define	XLS_FALV_COL_DOC_NAME		3
#define	XLS_FALV_ROW_DOC_USER		5
#define	XLS_FALV_COL_DOC_USER		3
#define	XLS_FALV_ROW_DOC_DATE		6
#define	XLS_FALV_COL_DOC_DATE		3
#define	XLS_FALV_ROW_DOC_CAMP		7
#define	XLS_FALV_COL_DOC_CAMP		3

#define	XLS_FALV_ROW_TOTCELL		9
#define	XLS_FALV_ROW_CHKCELL		10
#define	XLS_FALV_COL_INFO			4

#define	XLS_FALV_ROW_DATA_INIT		13
#define	XLS_FALV_COL_VIRT_X			1
#define	XLS_FALV_COL_VIRT_Y			2
#define XLS_FALV_COL_OBJ			3
#define XLS_FALV_COL_OBJT			4
#define XLS_FALV_COL_QUOTE			5
#define XLS_FALV_COL_DATE			6

#define FALV_FILE_NAME_LENGHT		127	

#define FALV_MAX_ROW				XLS_FALV_ROW_DATA_INIT + N_MAX_FALV

//Define righe colonne foglio Excel template DMP.//
#define	XLS_DMP_ROW_DOC_TYPE		3
#define	XLS_DMP_COL_DOC_TYPE		3
#define	XLS_DMP_ROW_DOC_NAME		4
#define	XLS_DMP_COL_DOC_NAME		3
#define	XLS_DMP_ROW_DOC_USER		5
#define	XLS_DMP_COL_DOC_USER		3
#define	XLS_DMP_ROW_DOC_DATE		6
#define	XLS_DMP_COL_DOC_DATE		3
#define	XLS_DMP_ROW_DOC_CAMP		7
#define	XLS_DMP_COL_DOC_CAMP		3

#define	XLS_DMP_ROW_TOTCELL			9
#define	XLS_DMP_ROW_CHKCELL			10
#define	XLS_DMP_COL_INFO			4

#define	XLS_DMP_ROW_DATA_INIT		13
#define	XLS_DMP_COL_VIRT_X			1
#define	XLS_DMP_COL_VIRT_Y			2
#define XLS_DMP_COL_QUOTE			3
#define XLS_DMP_COL_DATE			4

#define DMP_FILE_NAME_LENGHT		127	

#define DMP_MAX_ROW					XLS_DMP_ROW_DATA_INIT + N_MAX_DMP

//Define righe colonne foglio Excel template MOV.//
#define	XLS_MOV_ROW_DOC_NAME		3
#define	XLS_MOV_COL_DOC_NAME		5
#define	XLS_MOV_ROW_DOC_DATE		4
#define	XLS_MOV_COL_DOC_DATE		5
#define	XLS_MOV_ROW_DOC_USER		5
#define	XLS_MOV_COL_DOC_USER		5
#define	XLS_MOV_ROW_DOC_CAMP		6
#define	XLS_MOV_COL_DOC_CAMP		5

#define	XLS_MOV_ROW_DATA_INIT		9
#define	XLS_MOV_COL_NUM				1
#define	XLS_MOV_COL_MOV				2
#define XLS_MOV_COL_SP				3
#define XLS_MOV_COL_START_POS		4
#define XLS_MOV_COL_RES				5
#define XLS_MOV_COL_START_TIME		6
#define XLS_MOV_COL_END_TIME		7
#define XLS_MOV_COL_OPERATOR		8
#define XLS_MOV_COL_OP_MODE			9

#define MOV_FILE_NAME_LENGHT		127

#define MOV_MAX_ROW					XLS_MOV_ROW_DATA_INIT + N_MAX_RPMB

//Define righe colonne foglio Excel template FA.//
#define	XLS_FA_ROW_DOC_NAME			3
#define	XLS_FA_COL_DOC_NAME			3
#define	XLS_FA_ROW_DOC_USER			4
#define	XLS_FA_COL_DOC_USER			3
#define	XLS_FA_ROW_DOC_DATE			5
#define	XLS_FA_COL_DOC_DATE			3
#define	XLS_FA_ROW_DOC_CAMP			6
#define	XLS_FA_COL_DOC_CAMP			3
#define	XLS_FA_ROW_CONT_TYPE		8
#define	XLS_FA_COL_CONT_TYPE		4

#define	XLS_FA_ROW_DATA_INIT		11
#define	XLS_FA_COL_NAME				1
#define	XLS_FA_COL_TYPE				2
#define	XLS_FA_COL_VIRT_X			3
#define	XLS_FA_COL_VIRT_Y			4
#define	XLS_FA_COL_EXTR_Z1			5
#define	XLS_FA_COL_EXTR_Z1_RES		6
#define	XLS_FA_COL_INST_Z2			7
#define	XLS_FA_COL_INST_Z2_RES		8
#define	XLS_FA_COL_INST_Z3			9
#define	XLS_FA_COL_INST_Z3_RES		10
#define	XLS_FA_COL_INST_Z3			9
#define	XLS_FA_COL_INST_Z3_RES		10
#define	XLS_FA_COL_EXTR_Z3			11
#define	XLS_FA_COL_EXTR_Z3_RES		12
#define	XLS_FA_COL_INST2_Z2			13
#define	XLS_FA_COL_INST2_Z2_RES		14
#define	XLS_FA_COL_INST_Z1			15
#define	XLS_FA_COL_INST_Z1_RES		16

#define FA_MAX_ROW					XLS_FA_ROW_DATA_INIT + N_MAX_OBJE

VRP_API RETSTAT BuildReport(int reportType, TCHAR userName[SZUNAM+1]);
VRP_API RETSTAT BuildReportEx(bool reportType[N_MAX_REP], TCHAR userName[SZUNAM+1]);
VRP_API RETSTAT CheckReportFeasibility(int reportType, int *flag);
void GetFileNameFromPath(char *path, TCHAR filename[32]);
#endif